
#ifndef _TY_PATTERN_H_
#define _TY_PATTERN_H_

#include <stddef.h>

namespace tylenol { namespace pattern {


template <typename T>
class CSingleton
{
protected:
	CSingleton() {}

	virtual ~CSingleton()
	{
		pInstance = NULL;
	}

public:
	static T* GetInstance()
	{
		if(NULL == pInstance)
			pInstance = new T;
		return pInstance;
	}

private:
	CSingleton(const CSingleton&);
	CSingleton& operator=(const CSingleton&);
	static	T *pInstance;
};

template <typename T>
T *CSingleton<T>::pInstance = NULL;


} /*pattern*/ } /*tylenol*/


#endif /* _TY_PATTERN_H_ */
